package org.apak.frontend;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apak.db.DBConnection;
import org.apak.db.RepairServiceDAO;
import org.apak.log.FileLogger;

@SuppressWarnings("serial")
public class ServiceTypeServlet extends HttpServlet {
	
	private Connection connection;
	private HttpSession session;
	
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		RepairServiceDAO dao = null;
		FileLogger.logMessage("Forwarded to /serviceType by JQuery.");
		try {
			connection = DBConnection.getConnection();
			dao = new RepairServiceDAO();
			int price = dao.getServiceTypePrice(request.getParameter("typeName"));
			dao.closeConnection();
			System.out.println(price);
			response.getWriter().println(price);
		} catch (Exception e) {
			FileLogger.log("ServiceTypeServlet.service()", FileLogger.getStackTrace(e));
		}		
	}
	


}
